/******************************************************************************
*  Copyright (C), 2017-2020,Advanced Technology Institute of Suzhou. 
*  THIS IS AN UNPUBLISHED WORK CONTAINING CONFIDENTIAL AND PROPRIETARY 
*   
*******************************************************************************
*  File Name: FundDataHelper.h
*  Author: qh.zhang@atisz.ac.cn
*  Version: 1.0.0
*  Date: 2021-1-6
*  Description: brief
*  History: 
******************************************************************************/
#pragma once
#include <QString>
#include <QMap>
#include <QVector>
#include "cereal/archives/json.hpp"
#include "cereal/types/string.hpp"
struct OneFundInfo
{
    std::string strCode="000000";
    std::string strName;
    std::string strLastValue;
    std::string strLatestValue;
    std::string strVate = "0";
};


namespace cereal
{
    template <class Archive>
    void serialize(Archive &ar, OneFundInfo & cls)
    {
        ar(cereal::make_nvp("fundcode", cls.strCode));
        ar(cereal::make_nvp("name", cls.strName));
        ar(cereal::make_nvp("dwjz", cls.strLastValue));
        ar(cereal::make_nvp("gsz", cls.strLatestValue));
        ar(cereal::make_nvp("gszzl", cls.strVate));
    }
}



class FundDataHelper
{
public:

    static FundDataHelper* getInstance()
    {
        if (nullptr == m_pInstance)
        {
            m_pInstance = new FundDataHelper;
        }
        return m_pInstance;
    }

    static void releaseInstance()
    {
        if (nullptr != m_pInstance)
        {
            delete m_pInstance;
            m_pInstance = nullptr;
        }
    }

    bool getAllFundNames(QMap<QString,QString> &mapAllFundNames);
    bool getCurInfo(QVector<OneFundInfo> &vecFavFundsInfo);

protected:
    bool getAllFundNamesFromSever();


private:
    FundDataHelper() {};
    ~FundDataHelper() {};


private:
    static FundDataHelper* m_pInstance;

    QStringList m_lstFavoriteCodes;
    QMap<QString, QString> m_mapAllFundNames;
};

